<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>重写变量</title>

    <script>
        //使用var声明
        var a = 0;
        var a = 1;
        console.log(a);

        function myFunction() {
            var b = 2;
            var b = 3;

            console.log(b);
        }
        myFunction();

    </script>
    <script src="js/traceur.js"></script>
    <script src="js/bootstrap.js"></script>
    <script type="module">
        let a = 0;
        let a = 1; //TypeError

        function myFunction() {
            let b = 2;
            let b = 3; //TypeError
        }
    </script>

    <script type="module">
        var a = 1;
        let b = 2;
        function myFunction() {
            var a = 3; //跟全局声明的a变量是不同的变量
            let b = 4;
            if (true) {
                var a = 5; //变量覆盖
                let b = 6; //不同的变量
            }
        }
    </script>
</head>
</html>